<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>课堂作业3</title>
</head>

<body>

</body>
<script>
    // 3、请问下面的数据中，isok都为真吗？
    let date = [
        {
            id: '001',
            color: ['红', '黄', '蓝'],
            isok: false
        }, {
            id: '002',
            color: ['红', '黄', '蓝'],
            isok: true
        }, {
            id: '003',
            color: ['红', '紫', '绿'],
            isok: false
        }
    ]
    let res2 = date.every(function (item) {
        return item.isok
    })
    console.log(res2, 333);//false 333

    // 4、请问下面的数据中商品002的color有“红”色的吗？
    let res3 = false;
    data.forEach(function(item) {
        // console.log(item,555)
        if (item.id == '002') {
            console.log('满足数据的条件', item)
            let arr = item.color;
            // console.log(arr,999)
            //不要在forEach里面every
            //res3 = arr.every(function(item2){
            //  return item2.index('红') > -1   
            // })
            for (let i = 0; i < item.color.lenth; i++) {
                console.log(item.color[i])
                if (item.color[i].indexOF('红') > -1) {
                    res3 = true
                }
            }

            //console.log(res3,'里面的')
        }
    })

    console.log(res3, 444);//false 444


    //5.请把下面数据中，姓"刘"的同学找出来。返回数组
    //6.请把下面数据中，大于等于18岁的同学找出来。返回数组

    let studentList = [{
        id: 2021001,
        name: '罗至轩',
        age: 19
    }, {
        id: 2021002,
        name: '庄震灿',
        age: 19
    }, {
        id: 2021003,
        name: '郭健',
        age: 18
    }, {
        id: 2021004,
        name: '刘洌铒',
        age: 19
    }, {
        id: 2021005,
        name: '刘正',
        age: 17
    }]

    let arr5 = studentList.filter(function (item) {
        return item.name.includes('刘')
    })

    console.log(arr5, 999)
</script>

</html>